package net.mujiwulian.controller;

import net.mujiwulian.mapper.PersonMapper;
import net.mujiwulian.vo.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;


/**
 * @author zht
 * @version 1.0
 * @createDate 2020/06/01 18:26
 */
@Controller
public class SearchController {
    @Resource
    private PersonMapper personMapper;
    @GetMapping("/")
    public String toIndex(){
        return "index";
    }
    @GetMapping("/getColumns")
    @ResponseBody
    public List getColumns(){
        return personMapper.getDBColumns();
    }
    @PostMapping("/get")
    @ResponseBody
    public Result getPersonParams(@RequestBody List<String> searchData){
        List<Object> users=new ArrayList<>();
        if(searchData.size()!=0){
            Map<Long,Object> persons=personMapper.selectParams(searchData);
            persons.forEach((k,object)->{
                users.add(object);
            });
        }
        return new Result<>(Result.CodeStatus.OK,"success",users);
    }
}
